<!DOCTYPE html>
<html>
	<head>
		<include file="Public/head" />
		<link rel="stylesheet" href="__PUBLIC__/Manage/css/table.css">
		<title>用户列表</title>
		<style>
			.redText{
				color: red;font-size: 20px;
			}
		</style>
	</head>
	<body>
		<div class="nestable">
			<div class="console-title console-title-border drds-detail-title clearfix">
				<h5>用户列表</h5>
			</div>
			<form method="get" id="seachForm">
				<input type="hidden" name="m" value="User" />
				<input type="hidden" name="a" value="index" />
				<div class="public-selectArea">
					<div class="clearfix">
						<div class="wp_box col-xs-6">
							<dl>
								<dt>用户名：</dt>
								<dd>
									<input type="text" name="s-username" value="{$Think.get.s-username}">
								</dd>
							</dl>
						</div>
						<div class="wp_box col-xs-6">
							<dl>
								<dt>注册时间：</dt>
								<dd>
									<input type="date" class="time-inp" name="s-timeStart" value="{$Think.get.s-timeStart}" />
								</dd>
								<dd>
									<input type="date" class="time-inp" name="s-timeEnd" value="{$Think.get.s-timeEnd}" />
								</dd>
							</dl>
						</div>
					</div>
					<div class="btnArea">
						<a href='javascript:$("#seachForm").submit();' class="btn btn-sereachBg">
							<i class="glyphicon glyphicon-search public-ico"></i>
							<span class="public-label">查询</span>
						</a>
					</div>
				</div>
			</form>
			<div class="scroll-bar-table">
				<table class="table table-hover">
					<thead>
						<tr>
							<th>ID</th>
							<th>用户名</th>
							<th>姓名</th>
							<th>额度</th>
							<th>钱包</th>
							<th>状态</th>
							<th>注册时间</th>
							<th>借款统计</th>
							<th>账单统计</th>
							 
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
<php>$status=array('禁用','启用');</php>
<volist name="list" id="vo">
						<tr id="list-{$vo.id}">
							<td align="center">{$vo.id}</td>
							<td>{$vo.telnum}</td>
							<td>{$vo.username}</td>
							<td><span style="color: red;">{$vo.quota}</span> 元</td>
							<td><span style="color: red;">{$vo.qianbao}</span> 元</td>
							<td class="td-status">
								<a href="javascript:resetStatus('{$vo.id}','{$vo.status}');">{$status[$vo['status']]}</a>
							</td>
							<td>{$vo.reg_time|date="Y-m-d",###}</td>
							<td>
								成功借款<span class="redText">{$vo.succLoan}</span>次
							</td>
							<td>
								累计借款<span class="redText">{$vo.loanMoney}</span>元
							</td>
							 
							<td class="text-left">
								<a href="{:U('Info/view',array('uid'=>$vo['id']))}" target="_blank">查看资料</a>|
								<a href="javascript:resetQuota('{$vo.id}','{$vo.telnum}');">调整额度</a>|
								<a href="javascript:resetStatus('{$vo.id}','{$vo.status}');">{$status[$vo['status']]}</a> |
								<a href="javascript:resetPass('{$vo.id}','{$vo.telnum}');">重置密码</a>|
								<a href="javascript:delUser('{$vo.id}','{$vo.telnum}');">删除</a>
							</td>
						</tr>
</volist>
					</tbody>
				</table>
			</div>
			<div class="table-pagin-container">
				<div class="pull-right page-box">
					{$page}
				</div>
			</div>
		</div>
	</body>
	<script>
		//账户启用禁用
		function resetStatus(id,status){
			if(status == 1) status = 0;
			else status = 1;
			cvphp.post(
				"{:U('User/resetStatus')}",
				{
					id:id,
					status:status
				},
				function(data){
					if(data.status!=1){
						layer.msg(data.info);
					}else{
						var html;
						if(status == 1){
							layer.msg("账户已启用");
							html = '<a href="javascript:resetStatus('+"'"+id+"','1'"+');">启用</a>';
						}else{
							layer.msg("账户已禁用");
							html = '<a href="javascript:resetStatus('+"'"+id+"','0'"+');">禁用</a>';
						}
						$("#list-"+id+" .td-status").html(html);
					}
				}
			);
		}
		//调整额度
		function resetQuota(id,name){
			layer.prompt(
				{
					title: '输入用户  ['+name+'] 的新额度',
					formType: 0
				},
				function(quota,index){
					cvphp.post(
						"{:U('User/resetQuota')}",
						{
							id:id,
							quota:quota
						},
						function(data){
							if(data.status!=1){
								layer.msg(data.info);
							}else{
								layer.close(index);
								layer.msg("用户资料已保存");
								setTimeout(function(){location.reload();},1000);
							}
						}
					);
				}
			);
		}
		//修改账户手机号
		function resetTel(id,name){
			layer.prompt(
				{
					title: '输入用户  ['+name+'] 的新手机号',
					formType: 0
				},
				function(tel,index){
					cvphp.post(
						"{:U('User/resetTel')}",
						{
							id:id,
							tel:tel
						},
						function(data){
							if(data.status!=1){
								layer.msg(data.info);
							}else{
								layer.close(index);
								layer.msg("用户资料已保存");
								setTimeout(function(){location.reload();},1000);
							}
						}
					);
				}
			);
		}
		//修改账户银行卡号
		function resetBank(id,name){
			layer.prompt(
				{
					title: '输入用户新银行卡号',
					formType: 0
				},
				function(bank,index){
					cvphp.post(
						"{:U('User/resetBank')}",
						{
							id:id,
							bank:bank
						},
						function(data){
							if(data.status!=1){
								layer.msg(data.info);
							}else{
								layer.close(index);
								layer.msg("用户资料已保存");
								setTimeout(function(){location.reload();},1000);
							}
						}
					);
				}
			);
		}		
		//重置密码方法
		function resetPass(id,name){
			layer.confirm(
				'确认要重置用户[ '+name+' ]登录密码吗？',
				{
					btn: ['确认','取消']
				},function(){
					cvphp.post(
						"{:U('User/resetPass')}",
						{
							id:id
						},
						function(data){
							if(data.status!=1){
								layer.msg(data.info);
							}else{
								layer.alert("用户 ["+name+"] 密码已修改为  ["+data.info+"]");
							}
						}
					);
				}
			);
		}
		//删除会员方法
		function delUser(id,name){
			layer.confirm(
				'用户[ '+name+' ]删除后不可恢复且用户附带账单订单资料等同步删除不可恢复,确认要删除吗？',
				{
					btn: ['确认删除','取消']
				},function(){
					cvphp.post(
						"{:U('User/del')}",
						{
							id:id
						},
						function(data){
							if(data.status!=1){
								layer.msg(data.info);
							}else{
								$("#list-"+id).remove();
								layer.msg("操作成功");
							}
						}
					);
				}
			);
		}
	</script>
</html>